﻿using System.Collections;
using System.Collections.Generic;
using Network;
using System;

public class LogicMessageDispatcher : Singleton<LogicMessageDispatcher> {
    Dictionary<int, Action<object[]>> mMessageDictionary = new Dictionary<int, Action<object[]>>();

    public void RegisterMessageHandler(int messageId, Action<object[]> messageHandler)
    {
        if(mMessageDictionary.ContainsKey(messageId))
        {
            mMessageDictionary[messageId] += messageHandler;
        }
        else
        {
            mMessageDictionary[messageId] = messageHandler;
        }
    }

    public void UnregisterMessageHandler(int messageId, Action<object[]> messageHandler)
    {
        if(mMessageDictionary.ContainsKey(messageId))
        {
            mMessageDictionary[messageId] -= messageHandler;
        }
    }
	
}
